From 543b1c2f78010616b963d0dad0211ecd8e1d29a9 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Fri, 12 Mar 2004 22:41:32 +0000 Subject: [PATCH] Clamp the new size to the screen. Part of bug 129020. Fri Mar 12 23:37:15 2004 Soeren Sandmann * gtk/gtkfilechooserdialog.c (file_chooser_widget_default_realized_size_changed): Clamp the new size to the screen. Part of bug 129020. --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gtk/gtkfilechooserdialog.c | 33 +++++++++++++++++++++++++++++---- 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b2da00649..f070f86c29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Mar 12 23:37:15 2004 Soeren Sandmann + + * gtk/gtkfilechooserdialog.c + (file_chooser_widget_default_realized_size_changed): Clamp the + new size to the screen. + Fri Mar 12 15:06:44 2004 Owen Taylor * gtk/gtkexpander.c (gtk_expander_realize): Create the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7b2da00649..f070f86c29 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Fri Mar 12 23:37:15 2004 Soeren Sandmann + + * gtk/gtkfilechooserdialog.c + (file_chooser_widget_default_realized_size_changed): Clamp the + new size to the screen. + Fri Mar 12 15:06:44 2004 Owen Taylor * gtk/gtkexpander.c (gtk_expander_realize): Create the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7b2da00649..f070f86c29 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Fri Mar 12 23:37:15 2004 Soeren Sandmann + + * gtk/gtkfilechooserdialog.c + (file_chooser_widget_default_realized_size_changed): Clamp the + new size to the screen. + Fri Mar 12 15:06:44 2004 Owen Taylor * gtk/gtkexpander.c (gtk_expander_realize): Create the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7b2da00649..f070f86c29 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Fri Mar 12 23:37:15 2004 Soeren Sandmann + + * gtk/gtkfilechooserdialog.c + (file_chooser_widget_default_realized_size_changed): Clamp the + new size to the screen. + Fri Mar 12 15:06:44 2004 Owen Taylor * gtk/gtkexpander.c (gtk_expander_realize): Create the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7b2da00649..f070f86c29 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Fri Mar 12 23:37:15 2004 Soeren Sandmann + + * gtk/gtkfilechooserdialog.c + (file_chooser_widget_default_realized_size_changed): Clamp the + new size to the screen. + Fri Mar 12 15:06:44 2004 Owen Taylor * gtk/gtkexpander.c (gtk_expander_realize): Create the diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 24ea732b6e..4f61abe967 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -211,6 +211,29 @@ file_chooser_widget_update_hints (GtkFileChooserDialog *dialog) GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); } +static void +clamp_to_screen (GtkWidget *widget, + gint *width, + gint *height) +{ + GdkScreen *screen; + int monitor_num; + GdkRectangle monitor; + + g_return_if_fail (GTK_WIDGET_REALIZED (widget)); + + screen = gtk_widget_get_screen (widget); + monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); + + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + if (width) + *width = MIN (*width, (monitor.width * 3) / 4); + + if (height) + *height = MIN (*height, (monitor.height * 3) / 4); +} + static void file_chooser_widget_default_realized_size_changed (GtkWidget *widget, GtkFileChooserDialog *dialog) @@ -289,12 +312,14 @@ file_chooser_widget_default_realized_size_changed (GtkWidget *widget, priv->resize_horizontally = resize_horizontally; priv->resize_vertically = resize_vertically; - /* FIXME: We should make sure that we arent' bigger than the current screen */ if (dx != 0 || dy != 0) { - gtk_window_resize (GTK_WINDOW (dialog), - cur_width + dx, - cur_height + dy); + gint new_width = cur_width + dx; + gint new_height = cur_height + dy; + + clamp_to_screen (GTK_WIDGET (dialog), &new_width, &new_height); + + gtk_window_resize (GTK_WINDOW (dialog), new_width, new_height); } /* Only store the size if we can resize in that direction. */ -- 2.30.2